#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn=70;
int p[maxn+3], q[maxn+3], r[maxn+3], s[maxn+3], f[maxn+3][maxn+3][maxn+3][maxn+3];

inline int sqr(int a) {return a*a;}

inline int calc(int a, int b, int c, int d) {
    return sqr(p[a]-q[b])+sqr(p[b]-r[c])+sqr(p[c]-s[d]);
}

int main() {
    freopen("landmine.in", "r", stdin);
    freopen("landmine.out", "w", stdout);

    int n;
    scanf("%d", &n);
    for (int i=1; i<=n; i++) scanf("%d", p+i);
    for (int i=1; i<=n; i++) scanf("%d", q+i);
    for (int i=1; i<=n; i++) scanf("%d", r+i);
    for (int i=1; i<=n; i++) scanf("%d", s+i);

    // for (int l=2; l<=n+1; l++) {
    //     int r=l-2;
    //     f[l][r][n+2][l-1] = calc(0, l-1, n+1, n+2);
    // }
    // for (int l=1; l<=n+1; l++) {
    //     int r=l-1;
    //     f[l][r][n+2][l] = f[l][r][n+2][r] = max(calc(0, r, n+1, n+2)+calc(r, l, n+1, n+2),
    //                                             calc(0, l, n+1, n+2)+calc(0, r, l, n+1));
    // }

    for (int i=1; i<=n; i++) {
        for (int l=1; l+i-1<=n; l++) {
            int r=l+i-1;
            for (int u=r+2; u<=n+2; u++) {
                for (int v=l; v<=r; v++) {
                    int tf=0;
                    for (int nu=v+1; nu<=r; nu++) {
                        tf = max(tf, f[l][v-1][nu][l]+f[v+1][r][u][nu]);
                    }
                    tf = max(tf, f[l][v-1][r+1][l]+f[v+1][r][u][v+1]);
                    f[l][r][u][v] = max(tf+calc(l-1, v, r+1, u), f[l][r][u][v]);
                    for (int x=v+1; x<=r; x++) {
                        tf=0;
                        for (int nu=x+1; nu<=r; nu++) {
                            tf = max(tf, f[l][x-1][nu][v]+f[x+1][r][u][nu]);
                        }
                        tf = max(tf, f[l][x-1][r+1][v]+f[x+1][r][u][x+1]);
                        f[l][r][u][v] = max(tf+calc(l-1, x, r+1, u), f[l][r][u][v]);
                    }
                }
            }
        }
    }

    int ans=0;
    for (int i=1; i<=n; i++) {
        ans = max(ans, f[1][n][n+2][i]);
    }
    printf("%d\n", ans);

    fclose(stdin);
    fclose(stdout);
    return 0;
}
